<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>01-表单操作</title>
    <script>
        // value属性
        /*window.onload=function () {
            let btnEle = document.getElementById("btn");
            btnEle.onclick=function () {
                let usernameValue = document.frm1.username.value;
                alert(usernameValue);

            }
        }*/

        // checked 属性
        /*window.onload=function () {
            document.getElementById("btn1").onclick=function (){
                let children = document.frm2.children;
                for (let i = 0; i < children.length; i++) {
                    if (children[i].checked){
                        console.log(children[i]);
                    }
                }
            }
        }*/

        // selected 属性
        /*window.onload=function () {
            document.getElementById("btn2").onclick=function () {
                let children = document.getElementById("city").children;
                for (let i = 0; i < children.length; i++) {
                    if (children[i].selected){
                        alert(children[i].innerHTML);
                    }
                }
            }
        }*/

        // submit 方法
        /*window.onload=function () {
            document.getElementById("btn3").onclick=function () {
                document.frm3.submit();
            }
        }*/

        // disabled
        window.onload=function () {
            let btn4Ele = document.getElementById("btn4");
            btn4Ele.onclick=function () {
                btn4Ele.disabled=true;
            }
        }
    </script>
</head>
<body>

<input type="button" id="btn4" value="只能点击一次">

<!--<form action="#" name="frm3">
    <input type="text" name="username">
    <input type="button" id="btn3" value="提交">
</form>-->

<!--<form action="#" name="frm2">
    <select name="" id="city">
        <option value="1">北京</option>
        <option value="2">武汉</option>
        <option value="3">上海</option>
        <option value="4">广州</option>
    </select>
    <input type="button" id="btn2" value="提交">
</form>-->

<!--<form action="#" name="frm2">
    <input type="radio" name="sex" value="0" checked>男
    <input type="radio" name="sex" value="1" >女
    <input type="button" id="btn1" value="提交">
</form>-->

<!--<form action="#" name="frm1">
    用户名：<input type="text" name="username">
    <input type="button" value="提交" id="btn">
</form>-->
</body>
</html>